/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import entities.Application;
import entities.Application.Evaluation;

/**
 *
 * @author akefeli
 */
public class Evaluator {

    public Evaluation evaluate(Application app) {
        Evaluation result;
        try {
            int degreeYear = Integer.parseInt(app.getEducationSection().getEducationDegreeYears());
            double degreeGPA = Double.parseDouble(app.getEducationSection().getEducationGPA());
            int englishRW = Integer.parseInt(app.getEnglishSection().getEnglishReadWrite());
            int englishS = Integer.parseInt(app.getEnglishSection().getEnglishSpeak());
            int englishU = Integer.parseInt(app.getEnglishSection().getEnglishUnderstand());
            boolean englishGood = englishRW > 0 && englishS > 0 && englishU > 0;
            int cSkill = Integer.parseInt(app.getProgrammingSection().getProgrammingcLangSkill());
            int cPlusSkill = Integer.parseInt(app.getProgrammingSection().getProgrammingcplusLangSkill());
            int cSharpSkill = Integer.parseInt(app.getProgrammingSection().getProgrammingcsharpLangSkill());
            int javaSkill = Integer.parseInt(app.getProgrammingSection().getProgrammingjavaLangSkill());
            boolean atLeastOneSkillGreaterOrEqualToBasic = cPlusSkill >= 2 || cSkill >= 2 || cSharpSkill >= 2 || javaSkill >= 2;
            boolean dataStack = app.getProgrammingSection().isProgrammingdataStacksNotStudied();
            boolean dataLinked = app.getProgrammingSection().isProgrammingdataLinkedListNotStudied();
            boolean dataQueue = app.getProgrammingSection().isProgrammingdataQueuesNotStudied();
            boolean dataNoNotStudied = !dataStack && !dataLinked && !dataQueue;
            boolean mathCalc = app.getProgrammingSection().isProgrammingmathCalculusI();
            boolean mathCalc2 = app.getProgrammingSection().isProgrammingmathCalculusII();
            boolean mathStat = app.getProgrammingSection().isProgrammingprobabilityStatistics();
            boolean mathLinear = app.getProgrammingSection().isProgramminglinearAlgebra();
            boolean atLeastOneMath = mathCalc || mathCalc2 || mathStat || mathLinear;

            if (((degreeYear == 4 && degreeGPA >= 2.7) || (degreeYear == 3 && degreeGPA >= 3.7))
                    && englishGood
                    && atLeastOneSkillGreaterOrEqualToBasic
                    && dataNoNotStudied
                    && atLeastOneMath) {
                result = Evaluation.PASS;
            } else {
                result = Evaluation.FAIL;
            }
        } catch (Exception ex) {
            result = Evaluation.INCONCLUSIVE;
        }
        return result;
    }
}
